import os

import requests
from moviepy.video import *

header = {
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 '
                  'Safari/537.36 Edg/134.0.0.0',
}


num = 0
while True:
    format_num = "{:05d}".format(num)
    url =f"https://tx-safety-video.acfun.cn/mediacloud/acfun/acfun_video/706fb0ef728f2f48-63b54d320f466f0cd99d8426aaead92c-hls_720p_2.{format_num}.ts?pkey=ABC68FZ4cg5N66DBBMB-EOEhbM0qH85lx7Vi8BiQdBGALC5LhXGDvaVPoYBLYei2jakcRWSddaWZZhI4p6l1alPqX1e0ktnrX_wSDuak9U81ISBfDzckKcKvNwVMihSNm6jrNTTdzHy3Ok6bFQwJAvL_-nJiROKuOJ9fF9ZdSsDCdDfp63fVHpPki-qa3RVMBckDboIpE4P2P7PbdiY8jng4uyTzwsNg8mV5tfweRH4w_Gel69T2eM7WoRx4InRLMDM&safety_id=AAJ9Yo4HukCufAnLuTC-YpY9"

    response = requests.get(url, headers=header)
    print(response.status_code)
    if response.status_code != 200:
        print(response.status_code)
        break
    with open(f'./video/{num}.ts', 'wb') as f:
        f.write(response.content)
    num += 1
    print(f"已经下载第{num}视频")
print("下载完成")




